<template>
	<view class="pageBg">
		<exhibitionCard class="exhibitionCard" :data="data"></exhibitionCard>
		<form @submit="formSubmit">
			<view class="form">
				<formItem title="联系人" name="user_name" v-model="form.user_name"></formItem>
				<formItem title="手机号" name="mobile" v-model="form.mobile"></formItem>
				<formItem title="公司名称" name="corporation_name" v-model="form.corporation_name"></formItem>
				<formItem title="所属行业" name="profession" v-model="form.profession"></formItem>
				<formItem noBorder title="面积" choice :choiceArr="data.GoodsBoothResidue" name="bid" v-model="form.bid"></formItem>
			</view>
			<view class="uni-btn-v">
				<button class="btn" form-type="submit">提交申请</button>
			</view>
		</form>
	</view>
</template>

<script>
	import exhibitionCard from '@/components/wbz/exhibitionCard/exhibitionCard.vue';
	import formItem from '@/components/wbz/formItem/formItem.vue';
	import { checkPhone, emailReg, checksStr } from '@/utils/regular.js';
	export default {
		components: {
			exhibitionCard,
			formItem,
		},
		data() {
			return {
				form: {},
				data: {},
			};
		},
		onLoad() {
			this.data = uni.getStorageSync('wbzAdd');
		},
		methods: {
			async formSubmit(e) {
				const obj=e.detail.value
				if (!this.check(obj)) {
					return;
				}
				const { data } = await this.$api.goodsApply({...obj,goods_id:this.data.id});
				this.showToastMsg(data.msg)
				this.back()
				
			},
			// 校验
			check(obj) {
				console.log(obj)
				if (!checksStr(obj.user_name, '请输入联系人')) return false;
				if (!checkPhone(obj.mobile)) return false;
				if (!checksStr(obj.corporation_name, '请输入公司名称')) return false;

				if (!checksStr(obj.profession, '请输入所属行业')) return false;
				if (!checksStr(obj.bid, '请选择面积')) return false;
				return true;
			},
		},
	};
</script>
<style lang="scss" scoped>
	.pageBg {
		padding-top: $margin-width;
		padding-bottom: 200rpx;
		.exhibitionCard {
			margin-bottom: $submargin-width;
		}
		.form {
			width: 690rpx;
			overflow: hidden;
			background: #ffffff;
			border-radius: 20rpx;
			margin: 0 auto;
		}
		.uni-btn-v {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100%;
			width: 750rpx;
			height: 140rpx;
			background: #ffffff;
			display: flex;
			align-items: center;
			justify-content: center;
			.btn {
				width: 689rpx;
				height: 80rpx;
				background: #1fc28b;
				border-radius: 40rpx;
				line-height: 80rpx;
				text-align: center;
				color: #ffffff;
				font-size: $uni-font-size-15;
			}
		}
	}
</style>
